package factory;

import dao.NewsDao;
import dao.impl.NewsDaoImpl;
import dao.impl.NewsDaoMySqlImpl;
import dao.impl.NewsDaoOracleImpl;
import dao.impl.NewsDaoRedisImpl;

/**
 * 创建 NewsDao实例的工厂类
 */
public class SimpleDaoFactory {
    /**
     * 创建NewsDao 实例的工厂方法
     */
    public static NewsDao getInstance(String Key) {
//        return new NewsDaoImpl();
        switch (Key) {
            case "mysql":
                return new NewsDaoMySqlImpl();
            case "oracle":
                return new NewsDaoOracleImpl();
            case "redis":
                return new NewsDaoRedisImpl();
                default:
                    throw new RuntimeException("无效的数据库类型:"+Key+",DAO获取失败");

        }
    }
}
